package com.ruoyi.crm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.domain.CrmChecktel;
import com.ruoyi.crm.service.ICrmChecktelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电话记录Controller
 * 
 * @author ruoyi
 * @date 2024-01-11
 */
@RestController
@RequestMapping("/crm/checktel")
public class CrmChecktelController extends BaseController
{
    @Autowired
    private ICrmChecktelService crmChecktelService;

    /**
     * 查询电话记录列表
     */
    @PreAuthorize("@ss.hasPermi('crm:checktel:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmChecktel crmChecktel)
    {
        startPage();
        List<CrmChecktel> list = crmChecktelService.selectCrmChecktelList(crmChecktel);
        return getDataTable(list);
    }

    /**
     * 导出电话记录列表
     */
    @PreAuthorize("@ss.hasPermi('crm:checktel:export')")
    @Log(title = "电话记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CrmChecktel crmChecktel)
    {
        List<CrmChecktel> list = crmChecktelService.selectCrmChecktelList(crmChecktel);
        ExcelUtil<CrmChecktel> util = new ExcelUtil<CrmChecktel>(CrmChecktel.class);
        util.exportExcel(response, list, "电话记录数据");
    }

    /**
     * 获取电话记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('crm:checktel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(crmChecktelService.selectCrmChecktelById(id));
    }

    /**
     * 新增电话记录
     */
    @PreAuthorize("@ss.hasPermi('crm:checktel:add')")
    @Log(title = "电话记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmChecktel crmChecktel)
    {
        return toAjax(crmChecktelService.insertCrmChecktel(crmChecktel));
    }

    /**
     * 修改电话记录
     */
    @PreAuthorize("@ss.hasPermi('crm:checktel:edit')")
    @Log(title = "电话记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmChecktel crmChecktel)
    {
        return toAjax(crmChecktelService.updateCrmChecktel(crmChecktel));
    }

    /**
     * 删除电话记录
     */
    @PreAuthorize("@ss.hasPermi('crm:checktel:remove')")
    @Log(title = "电话记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(crmChecktelService.deleteCrmChecktelByIds(ids));
    }
}
